package com.xiangge.juanzi;

import java.util.Arrays;
import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入4位密码:");
        int pswd = input.nextInt();
        if (pswd<1000||pswd>9999){
            System.err.println("数据非法");
            return;
        }
        int[] arr = new int[4];
        arr[0] = pswd/1000;
        arr[1] = pswd%1000/100;
        arr[2] = pswd%100/10;
        arr[3] = pswd%10;
        System.out.println("原密码为："+Arrays.toString(arr));

        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i]+5;
        }
        System.out.println("原密码+5为："+Arrays.toString(arr));

        for (int i = 0; i < arr.length; i++) {
            arr[i] = arr[i]%10;
        }
        System.out.println("原密码再对10求余为："+Arrays.toString(arr));

        for (int i = 0; i < arr.length/2; i++) {
            int temp = arr[arr.length-1-i];
            arr[arr.length-1-i] = arr[i];
            arr[i] = temp;
        }
        System.out.println("原密码反转为："+Arrays.toString(arr));

    }
}
